# -*- coding: utf-8 -*-
import scrapy




class SegFaultSpider(scrapy.Spider):
    name = 'segf'
    start_urls = ['https://segmentfault.com/questions']

    def parse(self, response):
        for href in response.css('.summary h2 a::attr(href)'):
            full_url = response.urljoin(href.extract())
            yield scrapy.Request(full_url, callback=self.parseSegFault)

    def parseSegFault(self, response):
        yield {
            'title': response.css('.block-for-right-border h1 a::text').extract()[0],
            'views': response.css('.block-for-right-border .post-topheader__info.mb15 span::text').extract()[0],
            'url': response.url,
        }








